<style>
    SPAN.searchword { background-color:yellow; }
</style>
<?php
global $arrSite;
$intSiteID = $this->intSiteID;
$strQuery = $this->query;
$title = isset($arrSite[$intSiteID])?$arrSite[$intSiteID]['name']:'Tất cả';
$arrData = $this->arrData;
?>
<form name="frmSearch" method="GET">
    <div class="bar_main_search">
        <div class="bor_search">
            <?php
            if($strQuery!='')
            {
            ?>
            <input name="q" id="q" type="text" class="txt_input_search" value="<?php echo $strQuery;?>" maxlength="80"/>
            <?php
            }
            else
            {
            ?>
                <input name="q" id="q" type="text" maxlength="80" class="txt_input_search" onfocus="if(this.value==this.defaultValue) this.value=''" onblur="if(this.value=='') this.value=this.defaultValue" value="Tìm kiếm thông tin"/>
            <?php
            }
            ?>
            
        </div>
        <input type="submit" value="tìm kiếm" class="btn_main_search" />
    </div>
</form>
<?php
if($strQuery!='')
{

    
?>
    <div class="title_block_search box_width_common">
        <div class="left w220">
            <div class="txt_cate_search"><?php echo $title;?></div>
        </div>
        <form name="frmCalendar" method="GET" onsubmit="return submitSearchDate();">
            <div class="right">
                <?php
                if(count($arrData)>0)
                {
                ?>
                <div class="chose_search_item">
                    <div class="chose_item">Chọn ngày tháng</div>
                    <div class="search_item">
                        <div class="content_search_item">
                            <p class="txt_11"><b>Từ</b></p>
                            <div class="input_time">
                                <input name="q" id="q" type="hidden" class="txt_input_search" value="<?php echo $strQuery;?>"/>
                                <?php
                                if(!empty($this->arrParamUrl['start_year']))
                                {
                                ?>
                                    <input type="text" name="start_day" id="start_day" maxlength="2" class="w25" value="<?php echo $this->arrParamUrl['start_day'];?>"  onkeyup="checkChangeDate('start_day',1,31);"/>
                                    <input type="text" name="start_month" id="start_month" maxlength="2" class="w25" value="<?php echo $this->arrParamUrl['start_month'];?>" onkeyup="checkChangeDate('start_month',1,12);"/>
                                    <input type="text" name="start_year" id="start_year" maxlength="4" class="w40" value="<?php echo $this->arrParamUrl['start_year'];?>" onkeyup="checkChangeDate('start_year',2000,2100);"/>
                                <?php
                                }
                                else
                                {
                                ?>
                                    <input type="text" name="start_day" id="start_day" maxlength="2" class="w25" onfocus="if(this.value==this.defaultValue) this.value=''" onblur="if(this.value=='') this.value=this.defaultValue" value="DD" onkeyup="checkChangeDate('start_day',1,31);"/>
                                    <input type="text" name="start_month" id="start_month" maxlength="2" class="w25" onfocus="if(this.value==this.defaultValue) this.value=''" onblur="if(this.value=='') this.value=this.defaultValue" value="MM" onkeyup="checkChangeDate('start_month',1,12);"/>
                                    <input type="text" name="start_year" id="start_year" maxlength="4" class="w40" onfocus="if(this.value==this.defaultValue) this.value=''" onblur="if(this.value=='') this.value=this.defaultValue" value="YYYY" onkeyup="checkChangeDate('start_year',2000,2100);"/>
                                <?php
                                }
                                ?>
                                <div class="clear">&nbsp;</div>
                            </div>
                            <p class="txt_11"><b>đến</b></p>
                            <div class="input_time">
                                <?php
                                
                                if(!empty($this->arrParamUrl['end_year']))
                                {
                                ?>
                                    <input type="text" name="end_day" id="end_day" maxlength="2" class="w25" value="<?php echo $this->arrParamUrl['end_day'];?>" onkeyup="checkChangeDate('end_day',1,31);"/>
                                    <input type="text" name="end_month" id="end_month" maxlength="2" class="w25" value="<?php echo $this->arrParamUrl['end_month'];?>" onkeyup="checkChangeDate('end_month',1,12);"/>
                                    <input type="text" name="end_year" id="end_year" maxlength="4" class="w40" value="<?php echo $this->arrParamUrl['end_year'];?>" onkeyup="checkChangeDate('end_year',2000,2100);"/>
                                <?php
                                }
                                else
                                {
                                ?>
                                    <input type="text" name="end_day" id="end_day" maxlength="2" class="w25" onfocus="if(this.value==this.defaultValue) this.value=''" onblur="if(this.value=='') this.value=this.defaultValue" value="DD" onkeyup="checkChangeDate('end_day',1,31);"/>
                                    <input type="text" name="end_month" id="end_month" maxlength="2" class="w25" onfocus="if(this.value==this.defaultValue) this.value=''" onblur="if(this.value=='') this.value=this.defaultValue" value="MM" onkeyup="checkChangeDate('end_month',1,12);"/>
                                    <input type="text" name="end_year" id="end_year" maxlength="4" class="w40" onfocus="if(this.value==this.defaultValue) this.value=''" onblur="if(this.value=='') this.value=this.defaultValue" value="YYYY" onkeyup="checkChangeDate('end_year',2000,2100);"/>
                                <?php
                                }
                                ?>
                                <div class="clear">&nbsp;</div>

                            </div>
                            
                            <input type="submit" value="Chọn" class="btn_submit_time" />

                        </div>
                    </div>
                </div>
                <?php
                }
                ?>
            </div>
        </form>
    </div>
    
    <?php
    
    $dateGroup = '';
    if(count($arrData)>0)
    {
    ?>
    <div class="block_search_result box_width_common" id="result_search">
        <?php

        foreach($arrData as $key => $data)
        {
            $dateRecord = date('d/m/Y',$data['update_time']);
            if($dateRecord!= $dateGroup)
            {
                if($date!='')
                {
                    echo "</ul>";
                }
                echo '<p class="time_search_result">'.$dateRecord.'</p>';
                echo "<ul>";
            }
            $dateGroup = date('d/m/Y',$data['update_time']);
        ?>
                <li>
                    <div class="news_images block_image_thumb">
                        <?php

                        //Get Share Link
                        if(strpos($data['share_url'],'http://')===false)
                        {
                            $link = $arrSite[$data['site_id']]['domain'].$data['share_url'];
                        }
                        else
                        {
                            $link = $data['share_url'];
                        }

                        if(!empty($data['thumbnail_url']))
                        {
                            if(isset($arrSite[$data['site_id']]['domain_image']))
                            {
                                $staticImage = $arrSite[$data['site_id']]['domain_image'];
                            }
                            else
                            {
                                $staticImage = $arrSite[$data['site_id']]['domain'];
                            }
                            $image = $staticImage.'/'.$data['thumbnail_url'];
                            
                        ?>
                        <a href="<?php echo $link;?>" target="_blank" title="<?php echo $data['title'];?>" alt="<?php echo $data['title'];?>">
                                <img src="<?php echo $image;?>" alt="" width="123" height="93"/>
                                <?php
                                if(!empty($this->arrParamUrl) && $this->arrParamUrl['video']=='on')
                                {
                                ?>
                                    <span class="icon_play">&nbsp;</span>
                                <?php
                                }
                                ?>
                            </a>
                        <?php
                        }
                        ?>
                        <p>
                            <a href="<?php echo $link;?>" target="_blank" title="<?php echo $data['title'];?>" alt="<?php echo $data['title'];?>" class="txt_black_hover_blue hightlight">
                                <b><?php echo $data['title'];?></b>
                            </a>
                        </p>
                        <p class="txt_gray txt_11"><?php echo date('d/m/Y H:i:s',$data['update_time']);?> 
                        | <b><?php echo $data['description'];?></b><!--<span class="icon_portal_thethao icon_commend">&nbsp;</span> 32--></p>
                        <p><span class="hightlight"><?php echo $data['lead'];?></span></p>
                    </div>
                </li>
        
        <?php
            if($key==(LIMIT_SEARCH-1))
            {
                echo "</ul>";
            }
        }
        ?>
        
    </div>
    <?php
    }
    else
    {
    ?>
        <div style="text-align: center;margin-top: 100px;">Không tìm thấy kết quả với từ khóa “<b><?php echo $strQuery;?></b>”</div>
<?php
    }
?>
    <div class="more_bottom_detal box_width_common">
        <?php
        if(count($arrData)>2)
        {
        ?>
            <div class="left"><a href="javascript:;" class="txt_gray" id="back-top"><span class="icon_portal_thethao icon_scrolltop">&nbsp;</span> Về đầu trang</a></div>

        <?php
        }
        ?>
        <?php
            echo $this->Pagination($this->arrParamPaging,LIMIT_SEARCH);
        ?>
    </div>
<?php
}
?>

<div class="clear">&nbsp;</div>

<?php if(count($arrData)>0){?>
<script type="text/javascript">
    $(document).ready(function(){
       localSearchHighlight('?h=<?php echo $this->query;?>');
    });
</script>
<?php } ?>
